package com.yqy.spring.service;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Order(1)
public class LogAspect {
    @Pointcut("execution(* com.yqy.spring.service.OrderService.*(..))")
    public void pointCut(){
    }
    @Before("pointCut()")
    public void beforeAdvice(){
        System.out.println("Log：前置通知");
    }
    @AfterReturning("pointCut()")
    public void afterReturningAdvice(){
        System.out.println("Log：后置通知");
    }
    @Around("pointCut()")
    public void aroundAdvice(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("Log：环绕通知开始");
        proceedingJoinPoint.proceed();
        System.out.println("Log：环绕通知结束");
    }
    @After("pointCut()")
    public void afterAdvice(){
        System.out.println("Log：最终通知");
    }
    @AfterThrowing("pointCut()")
    public void afterThrowingAdvice(){
        System.out.println("Log：异常通知");
    }
}
